﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using MikroObject;

namespace Aktarim
{
    public partial class frmSatisAktar : XtraForm
    {
        public frmSatisAktar()
        {
            InitializeComponent();
        }

        private void frmSatisAktar_Load(object sender, EventArgs e)
        {
            dateEdit1.DateTime = DateTime.Now.AddDays(-1);
        }

        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            progressBarControl1.Properties.Step = 1;
            progressBarControl1.Properties.PercentView = true;
            progressBarControl1.Properties.Minimum = 0;

            Data dt = new Data();
            dt.Server = Config.GetConfig.GetValue(CParams.PgServer, "127.0.0.1");
            dt.Password = Config.GetConfig.GetValue(CParams.PgPassword, "KORDO");
            dt.Port = int.Parse(Config.GetConfig.GetValue(CParams.PgPort, "5432"));
            dt.User = Config.GetConfig.GetValue(CParams.PgUserId, "begum");
            dt.Database = Config.GetConfig.GetValue(CParams.PgDatabase, "fastrest");
            Synchronous senk = new Synchronous();
            List<Evrak> evraklar = dt.SatisList(dateEdit1.DateTime);
            progressBarControl1.Properties.Maximum = evraklar.Count;
            foreach (int idx in senk.SatisAktar(evraklar))
            {
                progressBarControl1.PerformStep();
                progressBarControl1.Update();
            }
        }
    }
}
